<template>
  <div class="view">
    <div class="mask" v-if="show">2131</div>
    <u-modal :show="show" :asyncClose="true">
      <div class="content">
        <image src="@/static/icon/close.png" class="close"  @click="close"/>
        <image class="icon" src="@/static/icon/question.png" />
        <div class="text">{{tip}}</div>
      </div>
      <template #confirmButton>
        <div class="action">
          <u-button class="btn" type="primary" plain @click="close">取消</u-button>
          <u-button class="btn" type="primary" @click="confirm">确定</u-button>
        </div>
      </template>
    </u-modal>
  </div>
</template>

<script setup>
import { ref } from 'vue'
const show = ref(false)
const tip = ref('')
const emitData = ref()
const emits = defineEmits(['confirm'])
function open(data) {
  tip.value = data.tip
  show.value = true
  emitData.value = data.data
}
function close() {
  show.value = false
}
function confirm(){
  show.value = false
  emits('confirm',emitData.value)
}

defineExpose({
  open
})
</script>

<style lang="scss" scoped>
.mask {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100vh;
  width: 100vw;
  background: rgba($color: #000000, $alpha: 0.5);
  z-index: 10075;
}
.action {
  display: flex;
  gap: 22rpx;
  .btn {
    height: 88rpx;
    border-radius: 16rpx;
  }
}
.content {
  display: flex;
  justify-content: center;
  gap: 66rpx;
  margin-bottom: 44rpx;
  flex-direction: column;
  align-items: center;
  .icon {
    width: 144rpx;
    height: 144rpx;
  }
  .text {
    text-align: center;
  }
  .close {
    position: absolute;
    width: 40rpx;
    height: 40rpx;
    right: 30rpx;
    top: 30rpx;
  }
}
</style>